package com.cwh.taskcenter.reward.gateway;

import com.cwh.taskcenter.domain.reward.gateway.PointAccountGateWay;
import com.cwh.taskcenter.domain.reward.model.PointAccount;
import com.cwh.taskcenter.reward.converter.PointAccountConverter;
import com.cwh.taskcenter.reward.mapper.PointAccountMapper;
import com.cwh.taskcenter.reward.model.PointAccountDO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * @author cwh
 */
@Slf4j
@Repository
@RequiredArgsConstructor
public class PointAccountGateWayImpl implements PointAccountGateWay {

    @Autowired
    private PointAccountMapper pointAccountMapper;

    @Override
    public PointAccount findNormalByUserId(Long userId) {
        return null;
    }


    @Override
    public void saveOrUpdate(PointAccount pointAccount) {
        PointAccountDO pointAccountDO = PointAccountConverter.toPointAccountDO(pointAccount);
        if (pointAccountDO.getId() != null) {
            pointAccountMapper.update(pointAccountDO);
        }else {
            pointAccountMapper.create(pointAccountDO);
        }

    }
}
